<template>
    <div>
        <button @click='minusClick'>-</button>
        
        {{number}}

        <button @click='addClick'>+</button>
        
    </div>
</template>
<script>
    import bus from '../util/bus.js'
    export default{
        /*在computed中使用store中的数据*/
        computed:{
            number:function(){
                return this.$store.state.number
            }
        },
        methods:{
            addClick:function(){
                /*
                组件中可以通过this.$store.commit(函数名,参数)
                调用mutations中的函数来修改store中的数据
                */
                this.$store.commit('setNmuber',this.number+1)
            },
            minusClick:function(){
                this.$store.commit('setNmuber',this.number-1)
            }
        }
    }
</script>
<style scoped>
        
</style>